package com.atguigu.gmall.web.controller;

import com.atguigu.gmall.model.order.OrderInfo;
import com.atguigu.gmall.order.client.OrderFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/5/27 14:36
 * @Version 1.0
 */
@Controller
public class PaymentController {

    @Autowired
    private OrderFeignClient orderFeignClient;

    //  http://payment.gmall.com/pay.html?orderId=46
    @GetMapping("pay.html")
    public String pay(HttpServletRequest request){
        //  获取订单Id
        String orderId = request.getParameter("orderId");
        //  根据订单Id 获取订单对象
        OrderInfo orderInfo = orderFeignClient.getOrderInfo(Long.parseLong(orderId));
        request.setAttribute("orderInfo",orderInfo);
        return "payment/pay";
    }

    /**
     * 支付成功
     * @return
     */
    @GetMapping("/pay/success.html")
    public String success(){
        //  返回支付成功页面
        return "payment/success";
    }
}
